import request from '@/api/request';
import { AxiosPromise } from 'axios';
import { CommentQuery, CommentPageResult, CommentVO } from './types';

/**
 * 评论分页列表
 *
 * @param queryParams
 */
export function pageComment(queryParams: CommentQuery): AxiosPromise<CommentPageResult> {
  return request({
    url: '/api/v1/comment/page',
    method: 'get',
    params: queryParams
  });
}

/**
 * 回复评论分页列表
 *
 * @param queryParams
 */
export function pageReply(queryParams: CommentQuery): AxiosPromise<CommentPageResult> {
  return request({
    url: '/api/v1/comment/replyPage',
    method: 'get',
    params: queryParams
  });
}

/**
 * 评论表单数据
 *
 * @param id
 */
export function getCommentById(id: number): AxiosPromise<CommentVO> {
  return request({
    url: `/api/v1/comment/${id}`,
    method: 'get'
  });
}

/**
 * 新增评论
 *
 * @param data
 */
export function saveComment(data: CommentVO) {
  return request({
    url: '/api/v1/comment',
    method: 'post',
    data
  });
}

/**
 * 删除评论
 */
export function deleteComment(ids: number[]) {
  return request({
    url: '/api/v1/comment',
    method: 'delete',
    data: ids
  });
}
